Array.prototype.quickSort = function() {
  /**
   * 快速排序
   * @param {Array} array 待排序数组
   */
  const qsort = arr =>
    arr.length <= 1
      ? arr
      : qsort(arr.filter(x => x < arr[0]))
          .concat(arr.filter(x => x == arr[0]))
          .concat(qsort(arr.filter(x => x > arr[0])));

  return qsort(this);
};

console.log([5, 4, 3, 2, 1].quickSort()); // Array(5) [1, 2, 3, 4, 5]
